package com.spring.demo;

import java.io.IOException;
import java.io.InputStream;

import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

@Controller
@RequestMapping("/upload")
public class UploadController implements EnvironmentAware {

	private Environment environment;
	
	@RequestMapping("/doUpload")
	@ResponseBody
	public void upload(@RequestParam("uploadFile") MultipartFile uploadFile, @RequestParam("uploadFile2") MultipartFile uploadFile2) {
		
		try {
			InputStream input = uploadFile.getInputStream();
			
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	@RequestMapping("/index")
	public String index() {
		return "index";
	}

	public void setEnvironment(Environment environment) {
		this.environment = environment;
		System.out.println("environment : " + this.environment);
	}

}
